package ie.lawlor.amvc.controller;

import ie.lawlor.amvc.event.EventName;
import ie.lawlor.amvc.event.EventPayloadProxyFactory;

public class TerminateEvent extends ControllerEventWrapper {

    Object payload;

    EventPayloadProxyFactory payloadFactory;

    public TerminateEvent() {
        super();
    }

    public TerminateEvent(EventName componentEvent, EventName applicationEvent) {
        super(componentEvent, applicationEvent);
    }

    public void addToController(Controller controller) {
        if (payload != null) {
            controller.terminate(applicationEvent, componentEvent, override,
                    payload);
        } else if (payloadFactory != null){
            controller.terminate(applicationEvent, componentEvent, override, payloadFactory);
        } else {
            controller.terminate(applicationEvent, componentEvent, override);
        }
    }

    public Object getPayload() {
        return payload;
    }

    public void setPayload(Object payload) {
        this.payload = payload;
    }

    public EventPayloadProxyFactory getPayloadFactory() {
        return payloadFactory;
    }

    public void setPayloadFactory(EventPayloadProxyFactory payloadFactory) {
        this.payloadFactory = payloadFactory;
    }

}